package com.spring.reactive.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

import java.util.HashMap;

@RequestMapping("wc")
@RestController
public class WebClientController {


    @GetMapping("getUserInfo")
    public Mono<HashMap> getUserInfo(){

        return WebClient.builder().baseUrl("http://localhost:8080").build()
                .get()
                .uri("user")
                .accept(MediaType.APPLICATION_JSON)
                .exchangeToMono(response-> response.bodyToMono(HashMap.class));
    }


}
